//
//  FCIconButton.swift
//  miaoyin
//
//  Created by David on 2017/2/16.
//  Copyright © 2017年 David. All rights reserved.
//

import UIKit

class FCIconButton: UIButton {

    var iconButton: UIImageView!
    var textButton: UILabel!
    
    override init(frame: CGRect){
        super.init(frame: frame)
        iconButton = UIImageView(frame: CGRect(x: 0, y: 0, width: frame.height - 8, height: frame.height - 8))
        iconButton.center.x = frame.width/2
        addSubview(iconButton)
        textButton = UILabel(frame: CGRect(x: 0, y: frame.height - 8, width: frame.width, height: 8))
        textButton.textAlignment = .center
        textButton.font = UIFont.systemFont(ofSize: 10)
        addSubview(textButton)
    }
    
    override func setTitle(_ title: String?, for state: UIControlState) {
        textButton.text = title
    }
    
    override func setImage(_ image: UIImage?, for state: UIControlState) {
        iconButton.image = image
    }
    
//    override func addTarget(_ target: Any?, action: Selector, for controlEvents: UIControlEvents) {
//        iconButton.addTarget(target, action: action, for: controlEvents)
//        textButton.addTarget(target, action: action, for: controlEvents)
//    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */

}
